//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGUTTARUIS__MULTISEMA__H_
#define __SAGUTTARUIS__MULTISEMA__H_

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.h"
#if SAGITTARIUS_PLATFORM == SAGITTARIUS_PLATFORM_WIN
    #include <windows.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if SAGITTARIUS_IS_POSIX_VAR
    #define SG_DEF_MULTISEMA(name) multisema name
    #define SG_PASS_MULTISEMA(name) (&name)
    typedef uint32 multisema;
    typedef multisema* pmultisema;

    #define INITSEMA(sema) initsema(SG_PASS_MULTISEMA(sema))
    void initsema(pmultisema f);

    #define WLSEMA(sema) wlsema(SG_PASS_MULTISEMA(sema))
    #define WUSEMA(sema) wusema(SG_PASS_MULTISEMA(sema))
    void wlsema(pmultisema f);
    void wusema(pmultisema f);

    #define RLSEMA(sema) rlsema(SG_PASS_MULTISEMA(sema))
    #define RUSEMA(sema) rusema(SG_PASS_MULTISEMA(sema))
    void rlsema(pmultisema f);
    void rusema(pmultisema f);
#elif SAGITTARIUS_PLATFORM == SAGITTARIUS_PLATFORM_WIN
    #if SAGITTARIUS_WIN_MINVER >= SAGITTARIUS_WIN_MINVER_WIN7
        #define SG_DEF_MULTISEMA(name) multisema name
        #define SG_PASS_MULTISEMA(name) &name
        //typedef SRWLOCK multisema;
        //typedef PSRWLOCK pmultisema;
        typedef int multisema;
        typedef int pmultisema;

        #define INITSEMA(sema)

        #define WLSEMA(sema)
        #define WUSEMA(sema)

        #define RLSEMA(sema)
        #define RUSEMA(sema)
    #else
        #error "Windows slim locks are not supported on this version of Windows. Consider implementing DXUTLockFreePipe (see msdn.microsoft.com/en-us/library/windows/desktop/aa904937%28v=vs.85%29.aspx)"
    #endif
#else
    #error "No thread support"
#endif

#ifdef __cplusplus
}//extern "C"
#endif

#endif
